Skip to content

Add message, stream and URI factories for Slim Framework #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 14, 2016

Conversation

tuupola
Copy link
Contributor

@tuupola tuupola commented Oct 13, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
Documentation php-http/documentation#159
License MIT

What's in this PR?

This PR adds message, stream and URI factories for Slim Framework

Why?

Slim is reasonably popular PSR-7 based framework.

Example Usage

use Http\Client\Curl\Client;
use Http\Message\MessageFactory\SlimMessageFactory;
use Http\Message\StreamFactory\SlimStreamFactory;

$client = new Client(new SlimMessageFactory(), new SlimStreamFactory());

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Documentation pull request created (if not simply a bugfix)

To Do

  • Should something be added to puli.json?
  • Should these be named Slim3StreamFactory and Slim3StreamFactory instead?
  • Should there be more tests? This was so easy I feel like I am missing something.

@tuupola
Copy link
Contributor Author

tuupola commented Oct 13, 2016

Build fails on PHP 5.4 because Slim requires PHP >=5.5.0.

@sagikazarmark
Copy link
Member

@tuupola thank you for the PR. Can you try adding https://github.com/akeneo/PhpSpecSkipExampleExtension and skip the tests on PHP 5.4?

@tuupola
Copy link
Contributor Author

tuupola commented Oct 14, 2016

That might not be enough since also composer install fails. I see what I can do with the Travis build matrix.

@sagikazarmark
Copy link
Member

@php-http/owners how about dropping PHP 5.4 support of this package too?

@Nyholm
Copy link
Member

Nyholm commented Oct 14, 2016

Dropping 5.4 is a no-brainer in my opinion. My general approach is that you should keep old PHP versions if there is no reson for bumping then. I believe @tuupola has an excellent reson here.

We had a discussion on twitter about supporting 5.4 because legacy project would not be able to update to HTTPlug without dropping support for 5.4. (Because of php-http/discovery).

@xabbuh
Copy link
Member

xabbuh commented Oct 14, 2016

As this library is only a dependency during development I would not use it as an argument to bump the minimum version requirements. Instead I would remove the dev requirement and install the package on Travis CI only for PHP >= 5.5 jobs and skip the example otherwise as @sagikazarmark suggested.

@sagikazarmark
Copy link
Member

@xabbuh the problem is that this way development is much harder. I would do the other way around: remove the library in CI on PHP 5.4. That way you can't develop it if you have 5.4, but the lib remains compatible with it.

@Nyholm
Copy link
Member

Nyholm commented Oct 14, 2016

Sure, Im fine with that.

@xabbuh
Copy link
Member

xabbuh commented Oct 14, 2016

@sagikazarmark Sounds good too.

@tuupola
Copy link
Contributor Author

tuupola commented Oct 14, 2016

I already have it the way @xabbuh explained. However comment by @sagikazarmark makes sense. I will do it over and commit soonish.

@@ -35,6 +35,9 @@ before_install:
install:
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction

before_script:
- if [[ "${TRAVIS_PHP_VERSION}" == "5.4" ]]; then composer remove slim/slim; fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this to before install AND add --no-update flag to composer. That way we only have to run compose once.

@@ -14,19 +14,22 @@
"php": ">=5.4",
"psr/http-message": "^1.0",
"php-http/message-factory": "^1.0.2",
"clue/stream-filter": "^1.3"
"clue/stream-filter": "^1.3",
"slim/slim": "^3.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only dev requirement, right?

Copy link
Contributor Author

@tuupola tuupola Oct 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be yes. But this way it still wont still work because. You cannot do the composer install and then composer remove slim/slim with PHP 5.4 anyway since it is the composer install which will fail. I try if --ignore-platform-reqs helps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand you. Also, please see my previous comment about moving the removal to before_install instead of before_script with --no-update. --no-update causes to update composer.json, but does not actually call install.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah disregard last comment. I did not know you can run composer remove with empty vendor.

},
"suggest": {
"zendframework/zend-diactoros": "Used with Diactoros Factories",
"guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories",
"slim/slim": "Used with Slim Factories",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diactoros and Guzzle PSR-7 are obviously meaning message factories while Slim is a framework. Can you please add some extra indication that it means message/PSR-7 factories? Just to avoid confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about wording. Maybe "Used with Slim Framework PSR-7 implementation" or "Used with Slim Framework PSR-7 messages"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any of those work for me

@tuupola
Copy link
Contributor Author

tuupola commented Oct 14, 2016

Seems there is problem with streams with hhvm. Will install hhvm locally to figure it out.

@tuupola
Copy link
Contributor Author

tuupola commented Oct 14, 2016

I would also like to add something to message factory tests. Namely I would like to test that factories set the message headers and body correctly. Should this be a separate PR?

@Nyholm
Copy link
Member

Nyholm commented Oct 14, 2016

Great job. Thank you!

@Nyholm Nyholm merged commit 51a0aa5 into php-http:master Oct 14, 2016
@sagikazarmark
Copy link
Member

@Nyholm there were some TODOs which indeed would have been nice to have here.

@Nyholm
Copy link
Member

Nyholm commented Oct 14, 2016

Sorry, I must have missed that. I saw that you approved it so I made a final review myself.

What were the TODOs?

@sagikazarmark
Copy link
Member

See the TODO section: puli.json, possibly rename to Slim3

@Nyholm
Copy link
Member

Nyholm commented Oct 14, 2016

Sorry for not bringing those up to discussion before merging.

Yes, some entries should be added to Puli.json. The other two are fine IMHO

@tuupola
Copy link
Contributor Author

tuupola commented Oct 15, 2016

I am not familiar with Puli. How should I add the entries to puli.json? I quickly read through puli docs but did not become any smarter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants